package com.lg.mengbase.testlistview;

import android.view.LayoutInflater;
import android.widget.ListView;

import com.lg.baselibrary.activity.BaseToolbarActivity;
import com.lg.mengbase.R;
import com.lg.mengbase.entity.ItemData;
import com.lg.mengbase.testlistview.adapter.MyAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by LiGang on 2017/5/27.
 */

public class TestBaseListViewAdapterActivity extends BaseToolbarActivity {
    @BindView(R.id.listView)
    ListView listView;
    private MyAdapter adapter;
    @Override
    protected int provideContentViewLayout() {
        return R.layout.activity_listview;
    }
    @Override
    protected void initTitle() {
        setToolbarTitle("BaseAbsListViewAdapter");
    }
    @Override
    protected void initView() {
        ButterKnife.bind(this);
    }

    @Override
    protected void initData() {
        adapter = new MyAdapter(this,listView);
        listView.addHeaderView(LayoutInflater.from(this).inflate(R.layout.header,listView,false));
        listView.addHeaderView(LayoutInflater.from(this).inflate(R.layout.header,listView,false));
        listView.addHeaderView(LayoutInflater.from(this).inflate(R.layout.header,listView,false));
        listView.addFooterView(LayoutInflater.from(this).inflate(R.layout.footer,listView,false));
        adapter.setDatas(getDatas());
        listView.setAdapter(adapter);
    }
    private int[] imgIds = {R.mipmap.head1,R.mipmap.head2,R.mipmap.head3,R.mipmap.head4
            ,R.mipmap.head5,R.mipmap.head6,R.mipmap.head7,R.mipmap.head8,R.mipmap.head9
            ,R.mipmap.head10,R.mipmap.head11,R.mipmap.head12,R.mipmap.head13,R.mipmap.head14,R.mipmap.head15};
    private List<ItemData> getDatas() {

        List<ItemData> datas = new ArrayList<>();
        for(int i = 0;i < imgIds.length;i++){
            datas.add(new ItemData("头像"+(i+1),imgIds[i]));
        }
        return datas;
    }
}
